package lab_08.com.acme.task3;

public class Task3Arrays {
	public static void main(String[] args) {
		for (int i = 1; i <= 50; i++) {
			if (i%3 == 0) {
				System.out.format("%1$d is multiple of 3\n",i);
			}		
		}
		
		int n = 50;
		int [] arr = new int[n];
		for (int i = 0; i < n; ++i) {
			arr[i] = i + 1;
		}
		
		if (n==0) {
			System.out.println("The array is of zero length.");
		}
		else {
			System.out.format("Average of 1,2,...,%1$d is %2$f",n,avg(arr));
		}
	}
		
	public static double avg(int [] arr) {
		int sum = 0;
		for (int i: arr) {
			sum += i;
		}
        if (arr.length == 0) {
        	return 0;
        }
		return (double) sum / arr.length;
	}
		
}
